1
|
|
|
/*! |
2
|
|
|
* Copyright (c) 2017 Rafael da Silva Rocha. |
3
|
|
|
* |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
View Code Duplication |
var assert = require('assert'); |
|
|
|
|
7
|
|
|
|
8
|
|
|
describe('read 32bit IEEE from disk and write to new file', function() { |
9
|
|
|
|
10
|
|
|
let fs = require("fs"); |
11
|
|
|
let wavefile = require("../index.js"); |
12
|
|
|
let path = "test/files/"; |
13
|
|
|
|
14
|
|
|
let wBytes = fs.readFileSync(path + "32bitIEEE-16kHz-bext-mono.wav"); |
15
|
|
|
let wav = new wavefile.WaveFile(wBytes); |
16
|
|
|
let wav2 = new wavefile.WaveFile(wav.toBytes()); |
17
|
|
|
fs.writeFileSync(path + "/out/32bitIEEE-16kHz-bext-mono.wav", wav2.toBytes()); |
18
|
|
|
|
19
|
|
|
it("toBytes should return a array of bytes", |
20
|
|
|
function() { |
21
|
|
|
assert.ok(wav.toBytes()); |
22
|
|
|
}); |
23
|
|
|
it("chunkId should be 'RIFF'", |
24
|
|
|
function() { |
25
|
|
|
assert.equal(wav2.chunkId, "RIFF"); |
26
|
|
|
}); |
27
|
|
|
it("subChunk1Id should be 'fmt '", |
28
|
|
|
function() { |
29
|
|
|
assert.equal(wav2.subChunk1Id, "fmt "); |
30
|
|
|
}); |
31
|
|
|
it("format should be 'WAVE'", |
32
|
|
|
function() { |
33
|
|
|
assert.equal(wav2.format, "WAVE"); |
34
|
|
|
}); |
35
|
|
|
it("subChunk1Size should be 16", |
36
|
|
|
function() { |
37
|
|
|
assert.equal(wav2.subChunk1Size, 16); |
38
|
|
|
}); |
39
|
|
|
it("audioFormat should be 3 (IEEE)", |
40
|
|
|
function() { |
41
|
|
|
assert.equal(wav2.audioFormat, 3); |
42
|
|
|
}); |
43
|
|
|
it("numChannels should be 1", |
44
|
|
|
function() { |
45
|
|
|
assert.equal(wav2.numChannels, 1); |
46
|
|
|
}); |
47
|
|
|
it("sampleRate should be 16000", |
48
|
|
|
function() { |
49
|
|
|
assert.equal(wav2.sampleRate, 16000); |
50
|
|
|
}); |
51
|
|
|
it("byteRate should be 64000", |
52
|
|
|
function() { |
53
|
|
|
assert.equal(wav2.byteRate, 64000); |
54
|
|
|
}); |
55
|
|
|
it("blockAlign should be 4", |
56
|
|
|
function() { |
57
|
|
|
assert.equal(wav2.blockAlign, 4); |
58
|
|
|
}); |
59
|
|
|
it("bitsPerSample should be 32", |
60
|
|
|
function() { |
61
|
|
|
assert.equal(wav2.bitsPerSample, 32); |
62
|
|
|
}); |
63
|
|
|
it("subChunk2Id should be 'data'", |
64
|
|
|
function() { |
65
|
|
|
assert.equal(wav2.subChunk2Id, 'data'); |
66
|
|
|
}); |
67
|
|
|
it("subChunk2Size should be > 0", |
68
|
|
|
function() { |
69
|
|
|
assert.ok(wav2.subChunk2Size > 0); |
70
|
|
|
}); |
71
|
|
|
it("samples.length should be > 0", |
72
|
|
|
function() { |
73
|
|
|
assert.ok(wav2.samples_.length > 0); |
74
|
|
|
}); |
75
|
|
|
it("samples_ on the new file should have the same length as in the original file", |
76
|
|
|
function() { |
77
|
|
|
assert.equal(wav2.samples_.length, wav.samples_.length); |
78
|
|
|
}); |
79
|
|
|
it("samples_ on the new file should be same as the original file", |
80
|
|
|
function() { |
81
|
|
|
assert.deepEqual(wav2.samples_, wav.samples_); |
82
|
|
|
}); |
83
|
|
|
}); |
84
|
|
|
|